package Box2D.Dynamics.Joints
{
	import Box2D.Common.Math.b2Vec2;
	import Box2D.Common.b2Wrapper;
	import Box2D.Dynamics.b2Body;

	/// Wheel joint definition. This requires defining a line of
	/// motion using an axis and an anchor point. The definition uses local
	/// anchor points and a local axis so that the initial configuration
	/// can violate the constraint slightly. The joint translation is zero
	/// when the local anchor points coincide in world space. Using local
	/// anchors and a local axis helps when saving and loading a game.	
	public class b2WheelJointDef extends b2JointDef
	{
		private var _localAnchorA:b2Vec2;
		private var _localAnchorB:b2Vec2;
		private var _localAxisA:b2Vec2;
		public function b2WheelJointDef()
		{
			super(callDirect('b2WheelJointDef_new'));
			_localAnchorA = new b2Vec2(0,0,wrapper+17);
			_localAnchorB = new b2Vec2(0,0,wrapper+25);
			_localAxisA = new b2Vec2(0,0,33);
		}
		public override function get cls():Class{return b2WheelJoint}
		
		/// Initialize the bodies, anchors, axis, and reference angle using the world
		/// anchor and world axis.
		public function Initialize(bodyA:b2Body, bodyB:b2Body, anchor:b2Vec2, axis:b2Vec2):void
		{
			call('b2WheelJointDef_Initialize',bodyA.wrapper,bodyB.wrapper,anchor.wrapper,axis.wrapper);
		}
		
		/// The local anchor point relative to body1's origin.
		public function get localAnchorA():b2Vec2{return _localAnchorA}
		public function set localAnchorA(value:b2Vec2):void{_localAnchorA.Copy(value)}
		
		/// The local anchor point relative to body2's origin.
		public function get localAnchorB():b2Vec2{return _localAnchorB}
		public function set localAnchorB(value:b2Vec2):void{_localAnchorB.Copy(value)}
		
		/// The local translation axis in body1.
		public function get localAxisA():b2Vec2{return _localAxisA}
		public function set localAxisA(value:b2Vec2):void{_localAxisA.Copy(value)}
		
		/// Enable/disable the joint motor.
		public function get enableMotor():Boolean{return getBoolean(41)}
		public function set enableMotor(value:Boolean):void{setBoolean(41,value)}
		
		/// The maximum motor torque, usually in N-m.
		public function get maxMotorTorque():Number{return getNumber(42)}
		public function set maxMotorTorque(value:Number):void{setNumber(42,value)}
		
		/// The desired motor speed in radians per second.
		public function get motorSpeed():Number{return getNumber(46)}
		public function set motorSpeed(value:Number):void{setNumber(45,value)}
		
		/// Suspension frequency, zero indicates no suspension
		public function get frequencyHz():Number{return getNumber(50)}
		public function set frequencyHz(value:Number):void{setNumber(50,value)}
		
		/// Suspension damping ratio, one indicates critical damping
		public function get dampingRatio():Number{return getNumber(54)}
		public function set dampingRatio(value:Number):void{setNumber(54,value)}
	}
}